from myspider.processor import BaseProcessor
import requests


class Job51Processor(BaseProcessor):
    def open_spider(self, spider):
        self.spider = spider

    def process(self, item):
        img_response = self.spider.session.get(item['image_addr'])
        with open("./images/{}.jpg".format(item['image_name']), "wb") as fp:
            fp.write(img_response.content)
        return item
